package org.ddr.control;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.ddr.board.BoardVO;
import org.ddr.board.dao.BbsDAO;

/**
 * Servlet implementation class BoardControl
 */
@WebServlet("/board/*")
public class BoardControl extends ControlServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public BoardControl() {
        super();
        // TODO Auto-generated constructor stub
    }
    
    public void list(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
    	
    	RequestDispatcher dispatcher = request
				.getRequestDispatcher("/WEB-INF/jsp/board/boardlist.jsp");
		dispatcher.forward(request, response);
		
	}
    
    
    
    public void addcontents(HttpServletRequest request, HttpServletResponse response) 
    		throws ServletException, IOException {
    	
    	RequestDispatcher dispatcher = request
				.getRequestDispatcher("/WEB-INF/jsp/board/inputboard.jsp");
		dispatcher.forward(request, response);	
    }
    
    public void create(HttpServletRequest request, HttpServletResponse response) 
    		throws Exception {
    		
    	response.setCharacterEncoding("UTF-8");
    	
    	BoardVO vo = new BoardVO();
    	vo.setUserId(request.getParameter("userid"));
    	vo.setTitle(request.getParameter("title"));
    	vo.setContents(request.getParameter("content"));
    	BbsDAO.instance.create(vo);	
    }
	
}
